30/03 2021 @Kofod95

Upload the files from this folder to the corresponding directories at the server. You might need to create some of the directories.
If you are using another template than "override", upload to that.
If you are not familiar with the template-system, learn more in the User-guide: https://phoenixcart.org/phoenixcartwiki/index.php?title=Welcome_to_CE_Phoenix_Wiki
Copy and translate the english language-files as needed. 

All credit goes to the original developer for the functionality.
All credit goes to the PhoenixCart core-developers for making it possible to install without modifying core.

##LEGACY##

INSTALL MANUAL for GIFTWRAP MODULE v1.1
-----------------------------------------
2015/12/01 Tsimi

This addon will allow you to activate a gift wrapping service checkbox in the checkout_shipping.php
You can also choose if you want to charge for this service or not. (Flat Rate or Per Item charge possible.)
Setting the fee price to 0 will charge nothing.
If you do charge a fee make sure that the sort order comes before the Total.
This module was tested with osC 2.3.4  and osC 2.3.4 BS GOLD.

Database changes will be installed/uninstalled automatically with the module.
Just very minor code additions to 3 core files.
As always, BACKUP all your files and database before attempting any installation.

IMPORTANT NOTE!
Be careful when reaching Step 1e! Make sure you use the code for "your" version of osC.
One is for normal osC 2.3.4 and one is for osC 2.3.4 BS GOLD

Activation:
------------

After installation go to your Admin Area -> Modules -> Order Total and click on the install button (top-right)
Then choose the Giftwrapping module and install it.
Click "Edit" and choose your settings and click the save button.
That's it!

New files:
-----------

catalog/includes/modules/order_total/ot_giftwrap.php
catalog/includes/languages/modules/order_total/ot_giftwrap.php

Files to amend:
----------------

checkout_shipping.php
checkout_process.php
includes/languages/english/checkout_shipping.php


Installation:
--------------

FIRST UPLOAD THE NEW FILES

*****************************************
STEP 1.) catalog/checkout_shipping.php
*****************************************

STEP 1a.)
FIND: (around line 109)

if (!tep_session_is_registered('shipping')) tep_session_register('shipping');

ADD AFTER:

// BOF GIFTWRAP
 if (!tep_session_is_registered('gift_wrap')) tep_session_register('gift_wrap');
	  $gift_wrap = isset($HTTP_POST_VARS['gift_wrap']) ? true : false;
// EOF GIFTWRAP


STEP 1b.)
FIND:

          if (isset($quote['error'])) {
            tep_session_unregister('shipping');
			
ADD RIGHT AFTER:

		// BOF GIFTWRAP
			tep_session_unregister('gift_wrap');
		// EOF GIFTWRAP

		
STEP 1c.)		
FIND:

              tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
            }
          }
        } else {
          tep_session_unregister('shipping');

ADD RIGHT AFTER:

		// BOF GIFTWRAP
		  tep_session_unregister('gift_wrap');
		// EOF GIFTWRAP

		
STEP 1d.)		
FIND:

      if ( defined('SHIPPING_ALLOW_UNDEFINED_ZONES') && (SHIPPING_ALLOW_UNDEFINED_ZONES == 'False') ) {
        tep_session_unregister('shipping');

ADD RIGHT AFTER:

		// BOF GIFTWRAP
		  tep_session_unregister('gift_wrap');
		// EOF GIFTWRAP		

		
STEP 1e.) *for normal osC 2.3.4	only	  
FIND:

<?php
            $radio_buttons++;
          }
        }
      }
    }
?>

ADD AFTER:

<!-- BOF GIFTWRAP //-->
<?php
  if (MODULE_ORDER_TOTAL_ALLOW_GIFTWRAP == 'true') {
  
  $gift_price = $currencies->display_price(MODULE_ORDER_TOTAL_GIFTWRAP_FEE, tep_get_tax_rate(MODULE_ORDER_TOTAL_GIFTWRAP_TAX_CLASS, $order->delivery['country']['id'], $order->delivery['zone_id']));
?>
    <tr>
        <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
    </tr>
    <tr bgcolor="#b1ffb1">
		<td>
		<?php 
			echo '<strong>' . TEXT_GIFTWRAP . '</strong><br>' . TEXT_HAVE_YOUR_ORDER_GIFT_WRAPPED; 
			if (MODULE_ORDER_TOTAL_GIFTWRAP_FEE > 0) echo '<br /><small>' . sprintf(TEXT_GIFTWRAP_FEE, $gift_price) . '</small>';
		?>
		</td>
		<td align="right" colspan="2"><?php echo tep_draw_checkbox_field('gift_wrap', '1', (($gift_wrap == 'true') ? true : false), 'onclick="checkBox(\'gift_wrap\')"'); ?></td>
    </tr>
	<tr>
		<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
    </tr> 
<?php
  }
?>
<!-- EOF GIFTWRAP //-->


STEP 1e.) *for osC 2.3.4 BS GOLD only	  
FIND:

      </tbody>
    </table>
  </div>

<?php
  }
?>

ADD AFTER:

<!-- BOF GIFTWRAP //-->
<?php
if (MODULE_ORDER_TOTAL_ALLOW_GIFTWRAP == 'true') {
?>
<div class="col-sm-6 col-xs-12 pull-right alert alert-success">
<?php
	$gift_price = $currencies->display_price(MODULE_ORDER_TOTAL_GIFTWRAP_FEE, tep_get_tax_rate(MODULE_ORDER_TOTAL_GIFTWRAP_TAX_CLASS, $order->delivery['country']['id'], $order->delivery['zone_id']));

	echo '<i class="fa fa-gift fa-2x">&nbsp;</i><strong>' . TEXT_GIFTWRAP . '</strong><br>' . TEXT_HAVE_YOUR_ORDER_GIFT_WRAPPED;
    echo '<div style="float:right;">' . tep_draw_checkbox_field('gift_wrap', '1', false) . '</div>';
	if (MODULE_ORDER_TOTAL_GIFTWRAP_FEE > 0) {
		if (MODULE_ORDER_TOTAL_PER_ITEM_GIFTWRAP == 'Flat Rate') {	
			echo '<br /><small>' . sprintf(TEXT_GIFTWRAP_FEE_FLAT_RATE, $gift_price) . '</small>';
		} else {
			echo '<br /><small>' . sprintf(TEXT_GIFTWRAP_FEE_PER_ITEM, $gift_price) . '</small>';
		}	
	}
?>	
</div>
<div class="clearfix"></div>
<?php
}
?>
<!-- EOF GIFTWRAP //-->

*****************************************
Step 2.) catalog/checkout_process.php
*****************************************

Step 2a.)
FIND:

		'currency' => $order->info['currency'], 

ADD AFTER

// BOF GIFTWRAP
		'gift_wrap' => $order->info['gift_wrap'],						
// EOF GIFTWRAP  

Step 2b.)
FIND:

  tep_session_unregister('comments');
  
ADD AFTER:

// BOF GIFTWRAP  
  tep_session_unregister('gift_wrap');
// BOF GIFTWRAP

***************************************************************
Step 3.) catalog/includes/languages/english/checkout_shipping.php
***************************************************************

ADD THIS BEFORE THE LAST ?>

// BOF GIFTWRAP
define('TEXT_GIFTWRAP', 'Gift Wrapping Service');
define('TEXT_HAVE_YOUR_ORDER_GIFT_WRAPPED', 'Have your products giftwrapped.');
define('TEXT_GIFTWRAP_FEE_FLAT_RATE', 'An additional fee of %s will be added to your order.');
define('TEXT_GIFTWRAP_FEE_PER_ITEM', 'An additional fee of %s <u>per item</u> will be added to your order.');
// EOF GIFTWRAP

********************************************
UPGRADE MANUAL
********************************************
This is for those of you that have already installed the previous Version.

***************************************************************
catalog/includes/languages/english/checkout_shipping.php
***************************************************************

FIND

// BOF GIFTWRAP
define('TEXT_GIFTWRAP', 'Giftwrap Service');
define('TEXT_HAVE_YOUR_ORDER_GIFT_WRAPPED', 'Have your products giftwrapped.');
define('TEXT_GIFTWRAP_FEE', 'An additional fee of %s will be added to your order.');
// EOF GIFTWRAP

REPLACE WITH

// BOF GIFTWRAP
define('TEXT_GIFTWRAP', 'Gift Wrapping Service');
define('TEXT_HAVE_YOUR_ORDER_GIFT_WRAPPED', 'Have your products giftwrapped.');
define('TEXT_GIFTWRAP_FEE_FLAT_RATE', 'An additional fee of %s will be added to your order.');
define('TEXT_GIFTWRAP_FEE_PER_ITEM', 'An additional fee of %s <u>per item</u> will be added to your order.');
// EOF GIFTWRAP


*****************************************
catalog/checkout_shipping.php
*****************************************
========================
FOR BOOTSTRAP VERSION
========================

FIND 

<!-- BOF GIFTWRAP //-->
<?php
if (MODULE_ORDER_TOTAL_ALLOW_GIFTWRAP == 'true') {
?>
<div class="col-sm-6 col-xs-12 pull-right alert alert-success">
<?php
	$gift_price = $currencies->display_price(MODULE_ORDER_TOTAL_GIFTWRAP_FEE, tep_get_tax_rate(MODULE_ORDER_TOTAL_GIFTWRAP_TAX_CLASS, $order->delivery['country']['id'], $order->delivery['zone_id']));

	echo '<i class="fa fa-gift fa-2x">&nbsp;</i><strong>' . TEXT_GIFTWRAP . '</strong><br>' . TEXT_HAVE_YOUR_ORDER_GIFT_WRAPPED;
    echo '<div style="float:right;">' . tep_draw_checkbox_field('gift_wrap', '1', false) . '</div>';
	if (MODULE_ORDER_TOTAL_GIFTWRAP_FEE > 0) echo '<br /><small>' . sprintf(TEXT_GIFTWRAP_FEE, $gift_price) . '</small>';
?>	
</div>
<div class="clearfix"></div>
<?php
}
?>
<!-- EOF GIFTWRAP //-->

REPLACE WITH

<!-- BOF GIFTWRAP //-->
<?php
if (MODULE_ORDER_TOTAL_ALLOW_GIFTWRAP == 'true') {
?>
<div class="col-sm-6 col-xs-12 pull-right alert alert-success">
<?php
	$gift_price = $currencies->display_price(MODULE_ORDER_TOTAL_GIFTWRAP_FEE, tep_get_tax_rate(MODULE_ORDER_TOTAL_GIFTWRAP_TAX_CLASS, $order->delivery['country']['id'], $order->delivery['zone_id']));

	echo '<i class="fa fa-gift fa-2x">&nbsp;</i><strong>' . TEXT_GIFTWRAP . '</strong><br>' . TEXT_HAVE_YOUR_ORDER_GIFT_WRAPPED;
    echo '<div style="float:right;">' . tep_draw_checkbox_field('gift_wrap', '1', false) . '</div>';
	if (MODULE_ORDER_TOTAL_GIFTWRAP_FEE > 0) {
		if (MODULE_ORDER_TOTAL_PER_ITEM_GIFTWRAP == 'Flat Rate') {	
			echo '<br /><small>' . sprintf(TEXT_GIFTWRAP_FEE_FLAT_RATE, $gift_price) . '</small>';
		} else {
			echo '<br /><small>' . sprintf(TEXT_GIFTWRAP_FEE_PER_ITEM, $gift_price) . '</small>';
		}	
	}
?>	
</div>
<div class="clearfix"></div>
<?php
}
?>
<!-- EOF GIFTWRAP //-->

========================
FOR NORMAL VERSION
========================

FIND

<!-- BOF GIFTWRAP //-->
<?php
  if (MODULE_ORDER_TOTAL_ALLOW_GIFTWRAP == 'true') {
  
  $gift_price = $currencies->display_price(MODULE_ORDER_TOTAL_GIFTWRAP_FEE, tep_get_tax_rate(MODULE_ORDER_TOTAL_GIFTWRAP_TAX_CLASS, $order->delivery['country']['id'], $order->delivery['zone_id']));
?>
    <tr>
        <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
    </tr>
    <tr bgcolor="#b1ffb1">
		<td>
		<?php 
			echo '<strong>' . TEXT_GIFTWRAP . '</strong><br>' . TEXT_HAVE_YOUR_ORDER_GIFT_WRAPPED; 
			if (MODULE_ORDER_TOTAL_GIFTWRAP_FEE > 0) echo '<br /><small>' . sprintf(TEXT_GIFTWRAP_FEE, $gift_price) . '</small>';
		?>
		</td>
		<td align="right" colspan="2"><?php echo tep_draw_checkbox_field('gift_wrap', '1', (($gift_wrap == 'true') ? true : false), 'onclick="checkBox(\'gift_wrap\')"'); ?></td>
    </tr>
	<tr>
		<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
    </tr> 
<?php
  }
?>
<!-- EOF GIFTWRAP //-->

REPLACE WITH

<!-- BOF GIFTWRAP //-->
<?php
  if (MODULE_ORDER_TOTAL_ALLOW_GIFTWRAP == 'true') {
  
  $gift_price = $currencies->display_price(MODULE_ORDER_TOTAL_GIFTWRAP_FEE, tep_get_tax_rate(MODULE_ORDER_TOTAL_GIFTWRAP_TAX_CLASS, $order->delivery['country']['id'], $order->delivery['zone_id']));
?>
    <tr>
        <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
    </tr>
    <tr bgcolor="#b1ffb1">
		<td>
		<?php 
			echo '<strong>' . TEXT_GIFTWRAP . '</strong><br>' . TEXT_HAVE_YOUR_ORDER_GIFT_WRAPPED; 
			if (MODULE_ORDER_TOTAL_GIFTWRAP_FEE > 0) {
				if (MODULE_ORDER_TOTAL_PER_ITEM_GIFTWRAP == 'Flat Rate') {
					echo '<br /><small>' . sprintf(TEXT_GIFTWRAP_FEE_FLAT_RATE, $gift_price) . '</small>';
				} else {
					echo '<br /><small>' . sprintf(TEXT_GIFTWRAP_FEE_PER_ITEM, $gift_price) . '</small>';
				}
			}
				?>
		</td>
		<td align="right" colspan="2"><?php echo tep_draw_checkbox_field('gift_wrap', '1', (($gift_wrap == 'true') ? true : false), 'onclick="checkBox(\'gift_wrap\')"'); ?></td>
    </tr>
	<tr>
		<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
    </tr> 
<?php
  }
?>
<!-- EOF GIFTWRAP //-->

********************************************
THE END
********************************************